Stricter rules when parsing time values to avoid UBSAN error#3148
Stricter rules when parsing time values to avoid UBSAN error#3148kevinbackhouse merged 2 commits intoExiv2:mainfrom
Conversation
Stricter rules when parsing time values to avoid UBSAN error.
|
@Mergifyio backport 0.28.x |
✅ Backports have been createdDetails
|
| // Basic format | ||
| auto tzhi = std::stoi(format.substr(0, posColon)); | ||
| if (tzhi > 23) | ||
| if (tzhi < -23 || tzhi > 23) |
There was a problem hiding this comment.
Could limit this (and one above) even more from -12 to 14 strictly speaking, but I guess this is just to keep the fuzzer from going to crazy...
Stricter rules when parsing time values to avoid UBSAN error (backport #3148)
|
@kevinbackhouse woun't it be better to use strtoul for some of these? |
I don't think that would help, because they get written into a struct with Lines 1003 to 1009 in b917b34 |
|
So a cast would turn negatives to 0? |
What I mean is: if we use Of course these integer overflows are completely harmless, and they don't happen on legitimate image files, so this PR is purely about silencing an irrelevant UBSAN error. |
This fixes a UBSAN error found by OSS-Fuzz: https://issues.oss-fuzz.com/issues/392928817
The error message is:
It happens here:
exiv2/src/value.cpp
Line 975 in 3b58bda
The integer overflow is harmless, but I have fixed it by making the parsing rules stricter.